<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>git基本命令 | sunJsona的个人博客</title>

  <!-- keywords -->
  

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="git基本命令12345678910111213141516171819git status //查看当前git情况 参数-sgit init //git 初始化git config --global user.name &amp;apos;&amp;apos;//设置用户名git config --global user.email &amp;apos;&amp;apos;//设置emailgit config --list">
<meta property="og:type" content="article">
<meta property="og:title" content="git基本命令">
<meta property="og:url" content="https://xiaochangzai.github.io/2020/07/07/git基本命令/index.html">
<meta property="og:site_name" content="sunJsona的个人博客">
<meta property="og:description" content="git基本命令12345678910111213141516171819git status //查看当前git情况 参数-sgit init //git 初始化git config --global user.name &amp;apos;&amp;apos;//设置用户名git config --global user.email &amp;apos;&amp;apos;//设置emailgit config --list">
<meta property="og:locale" content="Simple Chinese">
<meta property="og:updated_time" content="2020-07-07T05:00:13.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="git基本命令">
<meta name="twitter:description" content="git基本命令12345678910111213141516171819git status //查看当前git情况 参数-sgit init //git 初始化git config --global user.name &amp;apos;&amp;apos;//设置用户名git config --global user.email &amp;apos;&amp;apos;//设置emailgit config --list">
  
    <link rel="alternative" href="/atom.xml" title="sunJsona的个人博客" type="application/atom+xml">
  
  
    <link rel="icon" href="http://7xkj1z.com1.z0.glb.clouddn.com/head.jpg">
  
  <link rel="stylesheet" href="/css/style.css">
  
  

  <script src="//cdn.bootcss.com/require.js/2.3.2/require.min.js"></script>
  <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>

  
</head>
<body>
  <div id="container">
    <div id="particles-js"></div>
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img lazy-src="http://7xkj1z.com1.z0.glb.clouddn.com/head.jpg" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">sunJsona</a></h1>
		</hgroup>

		

		
			<div class="switch-btn">
				<div class="icon">
					<div class="icon-ctn">
						<div class="icon-wrap icon-house" data-idx="0">
							<div class="birdhouse"></div>
							<div class="birdhouse_holes"></div>
						</div>
						<div class="icon-wrap icon-ribbon hide" data-idx="1">
							<div class="ribbon"></div>
						</div>
						
						<div class="icon-wrap icon-link hide" data-idx="2">
							<div class="loopback_l"></div>
							<div class="loopback_r"></div>
						</div>
						
						
					</div>
					
				</div>
				<div class="tips-box hide">
					<div class="tips-arrow"></div>
					<ul class="tips-inner">
						<li>菜单</li>
						<li>标签</li>
						
						<li>友情链接</li>
						
						
					</ul>
				</div>
			</div>
		

		<div class="switch-area">
			<div class="switch-wrap">
				<section class="switch-part switch-part1">
					<nav class="header-menu">
						<ul>
						
							<li><a href="/">主页</a></li>
				        
							<li><a href="/archives">所有文章</a></li>
				        
						</ul>
					</nav>
					<nav class="header-nav">
						<div class="social">
							
						</div>
					</nav>
				</section>
				
				
				<section class="switch-part switch-part2">
					<div class="widget tagcloud" id="js-tagcloud">
						
					</div>
				</section>
				
				
				
				<section class="switch-part switch-part3">
					<div id="js-friends">
					
			          <a target="_blank" class="main-nav-link switch-friends-link" href="https://github.com/smackgg/hexo-theme-smackdown">smackdown</a>
			        
			        </div>
				</section>
				

				
			</div>
		</div>
	</header>				
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"></div>
  		<h1 class="header-author js-mobile-header hide">sunJsona</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				<img lazy-src="http://7xkj1z.com1.z0.glb.clouddn.com/head.jpg" class="js-avatar">
			</div>
			<hgroup>
			  <h1 class="header-author">sunJsona</h1>
			</hgroup>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
		        <div class="clearfix"></div>
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
				</div>
			</nav>
		</header>				
	</div>
</nav>
      <div class="body-wrap"><article id="post-git基本命令" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2020/07/07/git基本命令/" class="article-date">
  	<time datetime="2020-07-07T05:00:13.000Z" itemprop="datePublished">2020-07-07</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      git基本命令
      
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
        

        
        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="git基本命令"><a href="#git基本命令" class="headerlink" title="git基本命令"></a>git基本命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">git status //查看当前git情况 参数-s</span><br><span class="line">git init //git 初始化</span><br><span class="line">git config --global user.name &apos;&apos;//设置用户名</span><br><span class="line">git config --global user.email &apos;&apos;//设置email</span><br><span class="line">git config --list //查看配置</span><br><span class="line">git clone &apos;仓库地址&apos; //复制远程仓库到本地</span><br><span class="line">git add file // 提交文件到临时仓库</span><br><span class="line">git rm -cached &apos;文件路径&apos; 从临时仓库删除</span><br><span class="line">git commit -m &apos;描述内容&apos; // 把临时仓库文件提交到本地仓库</span><br><span class="line">git push -u origin master //提交到远程仓库</span><br><span class="line">git pull origin master从远程仓库拉回来</span><br><span class="line">git pull --rebase</span><br><span class="line">git diff</span><br><span class="line">git log </span><br><span class="line">git reset --hard 哈希值的前六位//回滚到之前的版本</span><br><span class="line">git branch v2 //添加一个分支v2</span><br><span class="line">git branch gh-pages //添加个可以直接浏览的分支 //浏览地址 sorry510.github.io/仓库名</span><br><span class="line">git checkout gh-pages </span><br><span class="line">git push origin gh-pages</span><br></pre></td></tr></table></figure>
<p>设置密码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.password &quot;xxxxxx(your password)&quot;</span><br></pre></td></tr></table></figure></p>
<p>设置远程仓库地址<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git remote add origin https://sorry510:xp28344655@github.com/sorry510/cms</span><br><span class="line">git remote -v 查看远程仓库地址</span><br><span class="line">git remote set-url origin https://github.com/sorry510/cms 修改地址</span><br><span class="line"></span><br><span class="line">git fetch origin php 更新远程上的php分支</span><br></pre></td></tr></table></figure></p>
<p>提交到远程仓库设置权限<br>修改.git/config<br>remote “origin”]<br>    url = <a href="https://github.com/sorry510/test.git" target="_blank" rel="noopener">https://github.com/sorry510/test.git</a><br>改为<br>remote “origin”]<br>    url = https://用户名:密码@github.com/sorry510/test.git<br>    例如//url = <a href="https://sorry510:xp28344655@github.com/sorry510/test.git" target="_blank" rel="noopener">https://sorry510:xp28344655@github.com/sorry510/test.git</a></p>
<h2 id="vi常用快捷键"><a href="#vi常用快捷键" class="headerlink" title="vi常用快捷键"></a>vi常用快捷键</h2><p>正常模式<br>启动vim后默认位于正常模式。不论位于什么模式，按下<esc>键(有时需要按两下）<br>都会进入正常模式。<br>ctrl+r 撤销 +u<br>插入模式<br>在正常模式中按下i, I, a, A等键（后面系列文章会详细介绍），会进入插入模式。</esc></p>
<p>命令模式<br>在正常模式中，按下：（冒号）键，会进入命令模式。<br>:w   保存文件但不退出vi<br>:w file 将修改另外保存到file中，不退出vi<br>:w!   强制保存，不推出vi<br>:wq  保存文件并退出vi<br>:wq! 强制保存文件，并退出vi<br>:q  不保存文件，退出vi<br>:q! 不保存文件，强制退出vi<br>:e! 放弃所有修改，从上次保存文件开始再编辑</p>
<p>:set nu 显示行数</p>
<p>可视模式<br>在正常模式按下v, V, <ctrl>+v，可以进入可视模式<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C &quot;chen.jinlong@vmicloud.com&quot;</span><br><span class="line"></span><br><span class="line">①   cd ~/.ssh/    【如果没有对应的文件夹，则执行  mkdir  ./.ssh】</span><br><span class="line">②  git config --global user.name &quot;xb12369&quot;</span><br><span class="line">③  git config --global user.email &quot;1234@qq.com&quot;</span><br><span class="line">④  ssh-keygen -t rsa -C &quot;1234@qq.com&quot;</span><br></pre></td></tr></table></figure></ctrl></p>
<p>合并分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git merge --no-ff  分支</span><br><span class="line"></span><br><span class="line">git checkout -b develop origin/develop</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2020/07/07/django入门之模板的用法/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">&lt;</strong>
      <div class="article-nav-title">
        
          django入门之模板的用法
        
      </div>
    </a>
  
  
    <a href="/2020/07/07/git工作流学习/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">git工作流学习</div>
      <strong class="article-nav-caption">&gt;</strong>
    </a>
  
</nav>

  
</article>


<div class="ds-share share" data-thread-key="git基本命令" data-title="git基本命令" data-url="https://xiaochangzai.github.io/2020/07/07/git基本命令/"  data-images="http://7xkj1z.com1.z0.glb.clouddn.com/head.jpg" data-content="git基本命令">
    <div class="ds-share-inline">
      <ul  class="ds-share-icons-16">
      	<li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
        <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
        <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
        <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
        <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>
      </ul>
      <div class="ds-share-icons-more">
      </div>
    </div>
 </div>
 





</div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
      <div class="footer-left">
        &copy; 2022 sunJsona
      </div>
        <div class="footer-right">
          <a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/smackgg/hexo-theme-smackdown" target="_blank">Smackdown</a>
        </div>
    </div>
  </div>
</footer>
    </div>
    
  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">


<script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: true,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false
	}
</script>
<script src="/js/main.js"></script>



<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>


  </div>
</body>
</html>